<template>
  <div class="page-home">
    <div class="home-entry">
      <div class="container">
        <!-- 左侧分类 -->
        <HomeCategory />
        <!-- banner轮播图 -->
        <HomeBanner />
        <!-- 新鲜好物 -->
        <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱">
          <template #right>
            <xtx-more></xtx-more>
          </template>
          <template #default>
            <ul ref="pannel" class="goods-list">
              <li v-for="item in newData" :key="item.id">
                <RouterLink :to="`/goods/${item.id}`">
                  <img :src="item.picture" v-imgLazy="item.picture" alt="" />
                  <p class="name">{{ item.name }}</p>
                  <p class="price">&yen;{{ item.price }}</p>
                </RouterLink>
              </li>
            </ul>
          </template>
        </HomePanel>
        <!-- 人气推荐 -->
        <!--
          识别 webcomponent 浏览器默认支持
          支持插槽
         -->
        <omePanel title="人气推荐" sub-title="人气爆款 不容错过">
          <template #default>
            <ul class="goods-list">
            <li v-for="item in newHot" :key="item.id">
              <RouterLink to="/">
                <img :src="item.picture" alt="" />
                <p class="name">{{ item.title }}</p>
                <p class="desc">{{ item.alt }}</p>
              </RouterLink>
            </li>
          </ul>
          </template>
        </omePanel>
      </div>
    </div>
  </div>
</template>
<script>
import HomeCategory from './components/home-category'
import HomeBanner from './components/home-banner'
import HomePanel from './components/home-panel'
import { getNewData } from './service/newData.js'
import { getNewHot } from './service/newHot.js'
export default {
  name: 'PageHome',
  components: { HomeCategory, HomeBanner, HomePanel },
  setup () {
    // 调用拆分出去的逻辑,一定写上返回值
    const { newData } = getNewData()
    const { newHot } = getNewHot()

    return {
      newData,
      newHot
    }
  }
}
</script>
<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
